package com.wicket.okrcomponent.biz.service.nb;


import cn.hutool.core.bean.BeanUtil;
import com.wicket.okrcomponent.biz.service.dto.req.CheckTimeScopeSearchReqDto;
import com.wicket.okrcomponent.biz.service.dto.req.ObtainTimeScopeSearchReqDto;
import com.wicket.okrcomponent.biz.service.dto.res.CheckTimeScopeSearchResDto;
import com.wicket.okrcomponent.biz.service.dto.res.ObtainTimeScopeSearchResDto;
import com.wicket.okrcomponent.biz.service.dto.res.ObtainTimeScopeSearchRespDto;
import com.wicket.okrcomponent.common.annotations.BanAuto;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Calendar;
import com.wicket.okrcomponent.biz.service.dto.res.CheckTimeScopeSearchRespDto;
import com.wicket.okrcomponent.biz.service.dto.req.ObtainReceiveFieldsReqDto;
import com.wicket.okrcomponent.biz.service.dto.res.ObtainReceiveFieldsRespDto;
import com.wicket.okrcomponent.biz.service.dto.req.CalculateAdditionOfTwoNumsReqDto;
import com.wicket.okrcomponent.biz.service.dto.res.CalculateAdditionOfTwoNumsRespDto;
import com.wicket.okrcomponent.biz.service.dto.req.CalculateSubtractOfTwoNumComReqDto;
import com.wicket.okrcomponent.biz.service.dto.res.CalculateSubtractOfTwoNumComRespDto;

/**
 * @author ： 手工接入方法
 * @since 2022/5/28 15:32
 *
 *
 * @version 1.0
 */
@Service
@BanAuto
public class NbSchemeOpenRecord {
    /**
     * code:timeEfficiencyCheck
     * name:M2检查时间范围（判断是否过期）
     * desc:undefined
     **/
    @BanAuto
    @Trace(operationName = "M2检查时间范围（判断是否过期）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public CheckTimeScopeSearchRespDto checkTimeScopeSearch(CheckTimeScopeSearchReqDto reqDto) {
        CheckTimeScopeSearchRespDto retData = new CheckTimeScopeSearchRespDto();
        int i = reqDto.getCompareTime().compareTo(reqDto.getCurrentTime());
        if (i < 0) {
            retData.setTimeCompareResult("BEFORE");
        } else if (i > 0) {
            retData.setTimeCompareResult("LATER");
        } else if (i == 0) {
            retData.setTimeCompareResult("PRESENT");
        }
        return retData;
    }

    /**
     * code:getTimeRange
     * name:M2获取时间范围查询（特殊方法）
     * desc:undefined
     **/
    @BanAuto
    @Trace(operationName = "" +
            "" +
            "M2获取时间范围查询（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ObtainTimeScopeSearchRespDto obtainTimeScopeSearch(ObtainTimeScopeSearchReqDto reqDto) {
        ObtainTimeScopeSearchRespDto retData = new ObtainTimeScopeSearchRespDto();
        Calendar cal = Calendar.getInstance();
        cal.setTime(reqDto.getSystemCurrentTime()); //设置起时间
        cal.add(Calendar.YEAR, reqDto.getAuthorizationNum().intValue()); //增加一年
        retData.setEndTime(cal.getTime());
        retData.setStartTime(reqDto.getSystemCurrentTime());
        return retData;
    }
/**
      * code:receptionService
      * name:M2-获取接收字段
      * desc:undefined
      * gen by moon at 9/17/2022, 6:58:49 AM
      *
      **/
     @Trace(operationName = "M2-获取接收字段")
     @Tags({@Tag(key = "参数",value = "arg[0]"),
     @Tag(key = "返回值",value = "returnedObj")})
      public ObtainReceiveFieldsRespDto obtainReceiveFields(ObtainReceiveFieldsReqDto reqDto) {
        return BeanUtil.toBean(reqDto,ObtainReceiveFieldsRespDto.class);
      }
/**
      * code:additionOfTwoNum
      * name:M2计算两个数值相加（特殊方法）
      * desc:undefined
      * gen by moon at 5/5/2023, 9:48:48 PM
      * 
      **/
     @Trace(operationName = "M2计算两个数值相加（特殊方法）")
     @Tags({@Tag(key = "参数",value = "arg[0]"),
     @Tag(key = "返回值",value = "returnedObj")})
      public CalculateAdditionOfTwoNumsRespDto calculateAdditionOfTwoNums(CalculateAdditionOfTwoNumsReqDto reqDto) {

         CalculateAdditionOfTwoNumsRespDto retData = new CalculateAdditionOfTwoNumsRespDto();

         retData.setCalcResult(reqDto.getCalcPara1().doubleValue() + reqDto.getCalcPara2().doubleValue());
         return retData;
      }
/**
      * code:subtractionOfTwoNum
      * name:M2-授权剩余数自动-1
      * desc:undefined
      * gen by moon at 5/5/2023, 9:48:49 PM
      * 
      **/
     @Trace(operationName = "M2-授权剩余数自动-1")
     @Tags({@Tag(key = "参数",value = "arg[0]"),
     @Tag(key = "返回值",value = "returnedObj")})
      public CalculateSubtractOfTwoNumComRespDto calculateSubtractOfTwoNumCom(CalculateSubtractOfTwoNumComReqDto reqDto) {
         CalculateSubtractOfTwoNumComRespDto retData = new CalculateSubtractOfTwoNumComRespDto();
         retData.setCalcResult(reqDto.getCalcPara2().doubleValue()-reqDto.getCalcPara1().doubleValue());
        return retData;
      }
    // 手工接入方法
}
